package cn.trigram.config;

import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * feign的请求拦截器
 */
public class FeignRequestInterceptor implements RequestInterceptor {


  @Override
  public void apply(RequestTemplate requestTemplate) {

    addHeader(requestTemplate, "test", "test");
  }

  protected void addHeader(RequestTemplate requestTemplate, String name, String... values) {

    if (!requestTemplate.headers().containsKey(name)) {
      requestTemplate.header(name, values);
    }

  }

}
